import java.awt.event.ActionEvent;
import java.util.ArrayList;


public class Income  implements java.io.Serializable  {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -6316068619770164153L;
	private String category, description, recurringEvery,date;
	private Double amount;

	public static ArrayList<Income> incomeList = new ArrayList<Income>();
	
	public Income(String date, String description,String category,Double amount, String recurringEvery) {
		//super();
		this.description = description;
		this.amount = amount;
		this.category = category;
		this.recurringEvery = recurringEvery;
		this.date = date;
	}
	
	public String toString(){
		return "Income Date: " + date + " Description: " + description + " Category: " + category + " Amount: " + amount + " Recurring: " + recurringEvery;
	}
	
	public static void btnAddIncome_actionPerformed(ActionEvent e)
	{			
		//if (validIncomeDetails() == false){	//Function to check that everything typed into each field is valid.

			Double dblAmt = Double.parseDouble(EnterIncome.tfAmount.getText());
			
			Income newIncome = new Income (EnterIncome.tfDate.getText(), EnterIncome.tfDescription.getText(), EnterIncome.cbCategory.getSelectedItem().toString(), dblAmt, EnterIncome.cbReoccuring.getSelectedItem().toString());//Creates a new patient from data entered into textfields.
			incomeList.add(newIncome);//Adds patientID to the patList arraylist.
			EnterIncome.incomeListModel.addElement(newIncome);//Adds the nearly created patient to the patient list model.     	
			clearDetails();
			
		//}
	}
	
	public static void btnClear_actionPerformed(ActionEvent e)
	{
		clearDetails();
	}
	
	public static void clearDetails()
	{
		EnterIncome.tfDate.setText("");
		EnterIncome.tfDescription.setText("");
		EnterIncome.tfAmount.setText("");
		EnterIncome.cbCategory.setSelectedIndex(0);
		EnterIncome.cbReoccuring.setSelectedIndex(0);		
	}
		
	public String getCategory() {
		return category;
	}
	public void setCategory(String category) {
		this.category = category;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getRecurringEvery() {
		return recurringEvery;
	}
	public void setRecurringEvery(String recurringEvery) {
		this.recurringEvery = recurringEvery;
	}
	public Double getAmount() {
		return amount;
	}
	public void setAmount(Double amount) {
		this.amount = amount;
	}
	public String getDate() {
		return date;
	}
	public void setDate(String date) {
		this.date = date;
	}	
}
